/**
 * @project lauwsys
 */
package com.chimoz.lauwsys.business.services;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import junit.framework.TestCase;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.chimoz.lauwsys.business.BrandManager;
import com.chimoz.lauwsys.domain.Brand;

/**
 * @author Christian Teguh
 * @created 4 Okt 2011 18.34.11
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( locations = {"classpath:/db/lauwsys-jpa.xml"} )
public class BrandServiceTestCase extends TestCase {

	@Autowired
	private BrandManager brandManager;
	
		
	@Test
	public void listAllBrand() throws Exception {
		int off = 1;
		Integer limit = new Integer(10);
		Integer offset = limit * off;
		Map<String, String> criteria = new HashMap<String, String>();
		criteria.put("limit", limit.toString());
		criteria.put("offset", offset.toString());
		List<Brand> brands = this.brandManager.listBrand(criteria);
		
		for ( Iterator<Brand> it = brands.iterator(); it.hasNext(); ) {
			Brand newBrand = it.next();
			System.out.println(newBrand.getId() + " - " + newBrand + " - " + newBrand.getCtime() + " - " + newBrand.getMtime());
		}
		
		assertEquals( brands.size(), limit.intValue() );
		
    }
	
}
